<%@ Import Namespace="System.IO" %>


<H2>Working with the Path class</H2>


<form runat=server>
	Enter a path name: <asp:textbox runat=Server id=PathName Columns=60 Text="c:\wrox\somefile.txt" />
	<input type=submit value="Analyse...">
</form>

<%

	if ( Page.IsPostBack ) then
		Response.Write("<BR>Root Path = ")
		Response.Write( Path.GetPathRoot(PathName.Text) )

		Response.Write("<BR>Directory = ")
		Response.Write( Path.GetDirectoryName(PathName.Text) )
		
		Response.Write("<BR>Filename = ")
		Response.Write( Path.GetFileName(PathName.Text) )

		Response.Write("<BR>Filename (without extension) = ")
		Response.Write( Path.GetFileNameWithoutExtension(PathName.Text) )

		if ( Path.HasExtension(PathName.Text) ) then
			Response.Write("<BR>Extension = ")
			Response.Write( Path.GetExtension(PathName.Text) )
		end if
		
		Response.Write("<BR>")

		Response.Write("<BR>Temporary Directory = ")
		Response.Write( Path.GetTempPath() )

		Response.Write("<BR>Directory Separator Character = ")
		Response.Write( Path.DirectorySeparatorChar )

		Response.Write("<BR>Alt Directory Separator Character = ")
		Response.Write( Path.AltDirectorySeparatorChar )

		Response.Write("<BR>Volume Separator Character = ")
		Response.Write( Path.VolumeSeparatorChar )

		Response.Write("<BR>Path Separator Character = ")
		Response.Write( Path.PathSeparator )
	
		Response.Write("<BR>Invalid Path Characters = ")
		Response.Write( HttpUtility.HtmlEncode(new String(Path.InvalidPathChars)) )
		
			
	end if

	Response.Write("<HR>")
	Response.Write( Path.ChangeExtension("c:\richard",".txt") )

	Response.Write("<br>")

	Response.Write( Path.Combine("c:\rich", "anderson" ) )

	Directory.SetCurrentDirectory("c:\windows")
	Response.Write("<br>")
	Response.Write( Path.GetFullPath("rich") )

	Response.Write("<br>")
	Response.Write( Path.GetTempFileName() )

	Response.Write("<br>")
	Response.Write( Path.IsPathRooted("c:\test") )

%>
